{include file="public/layout"/}
<body class="laytp-container">
<div class="layui-card">
    <div class="layui-card-body">
        <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-card layui-col-md12">
            <div class="layui-card-header">
                <div class="layui-card-header">
                    <div class="layui-tab layui-tab-brief">
                        <ul class="layui-tab-title">
                            {foreach name="group_list" item="group"}
                                <li {if $inc_type==$group['inc_type'] }class="layui-this"{/if} onclick="location.href='{$group['url']}'">{$group.name}</li>
                            {/foreach}
                        </ul>
                    </div>
                </div>
            </div>
            <div class="layui-card-body" pad15>
                <div class="layui-form" lay-filter="">
                    <div class="layui-tab layui-tab-brief" lay-filter="mytab">
                        <!--**************************基础设置******************************-->
                        <div class="layui-tab-content">
                            <div class="layui-tab-item layui-show">
                                <div class="layui-form-item">
                                    <label class="layui-form-label" style="width:130px">订单退款：</label>
                                    <div class="layui-input-inline" style="width:300px">
                                        <input type="radio" name="canrefund" title="关闭" value="0" {if empty($config['canrefund'])}checked{/if} />
                                        <input type="radio" name="canrefund" title="开启" value="1" {if !empty($config['canrefund'])}checked{/if} />
                                    </div>
                                    <div class="layui-form-mid layui-word-aux"></div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label" style="width:130px">订单评价：</label>
                                    <div class="layui-input-inline" style="width:300px">
                                        <input type="radio" name="comment" title="关闭" value="0" {if empty($config['comment'])}checked{/if} />
                                        <input type="radio" name="comment" title="开启" value="1" {if !empty($config['comment'])}checked{/if} />
                                    </div>
                                    <div class="layui-form-mid layui-word-aux"></div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label" style="width:130px">加入购物车：</label>
                                    <div class="layui-input-inline" style="width:300px">
                                        <input type="radio" name="can_cart" title="关闭" value="0" {if empty($config['can_cart'])}checked{/if} />
                                        <input type="radio" name="can_cart" title="开启" value="1" {if !empty($config['can_cart'])}checked{/if} />
                                    </div>
                                    <div class="layui-form-mid layui-word-aux">关闭后产品详情不显示加入购物车按钮</div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label" style="width:130px">购买产品：</label>
                                    <div class="layui-input-inline" style="width:300px">
                                        <input type="radio" name="can_buy" title="关闭" value="0" {if empty($config['can_buy'])}checked{/if} />
                                        <input type="radio" name="can_buy" title="开启" value="1" {if !empty($config['can_buy'])}checked{/if} />
                                    </div>
                                    <div class="layui-form-mid layui-word-aux">关闭后产品详情不显示立即购买按钮</div>
                                </div>
<!--                                <div class="layui-form-item">-->
<!--                                    <label class="layui-form-label" style="width:130px">分享产品背景图：</label>-->
<!--                                    <input type="hidden" name="posterbg" id="logo" class="layui-input"-->
<!--                                           value="{$config.store_logo}">-->
<!--                                    <button style="float:left;" type="button" class="layui-btn layui-btn-primary"-->
<!--                                            onclick="uploader(this)" upload-input="logo" upload-preview="logoPreview">-->
<!--                                        上传图片-->
<!--                                    </button>-->
<!--                                    <div class="layui-form-mid layui-word-aux" style="margin-left:10px;">-->
<!--                                        建议尺寸：200×200像素-->
<!--                                    </div>-->
<!--                                    <div id="logoPreview"-->
<!--                                         style="float:left;padding-top:10px;margin-left:160px;clear: both;">-->
<!--                                        <div class="layui-imgbox" style="width:100px;">-->
<!--                                            <div class="layui-imgbox-img"><img src="{$config.posterbg}"/></div>-->
<!--                                        </div>-->
<!--                                    </div>-->
<!--                                </div>-->
                                <div class="layui-form-item">
                                    <label class="layui-form-label" style="width:130px">线上充值说明：</label>
                                    <div class="layui-input-inline">
                                        <textarea type="text" name="recharge_desc" class="layui-textarea">{$config.recharge_desc}</textarea>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label" style="width:130px">线下充值说明：</label>
                                    <div class="layui-input-inline">
                                        <textarea type="text" name="recharge_offline_desc" class="layui-textarea">{$config.recharge_offline_desc}</textarea>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label" style="width:130px">每积分可抵扣(元)：</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="score_to_money" class="layui-input" value="{$config.score_to_money}">
                                    </div>
                                    <div class="layui-form-mid layui-word-aux">订单付款时一个积分可抵扣多少元，0表示不开启抵扣</div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label" style="width:130px">积分抵扣比例(%)：</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="score_max_bili" class="layui-input" value="{$config.score_max_bili}">
                                    </div>
                                    <div class="layui-form-mid layui-word-aux">积分最多可抵扣订单金额的比例</div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label" style="width:130px">AI聊天接口：</label>
                                    <div class="layui-input-inline" style="width:300px">
                                        <input type="radio" name="ai_api" title="阿里百炼" value="ali" {if empty($config['ai_api']) || $config['ai_api']=='ai_api'}checked{/if} lay-filter='ai_api' />
                                        <input type="radio" name="ai_api" title="DeepSeek" value="deepseek" {if  $config['ai_api']=='deepseek'}checked{/if} lay-filter='ai_api' />
                                    </div>
                                    <div class="layui-form-mid layui-word-aux"></div>
                                </div>
                                <div id="ai_ali" {if !empty($config['ai_api']) && $config['ai_api']!='ali'}style="display:none;"{/if}>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label" style="width:130px">阿里百炼APIkey：</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="ali_ai_key" class="layui-input" value="{$config.ali_ai_key}">
                                        </div>
                                        <div class="layui-form-mid layui-word-aux"></div>
                                    </div>

                                    <div class="layui-form-item">
                                        <label class="layui-form-label" style="width:130px">阿里百炼模型：</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="ali_ai_modle" class="layui-input" value="{$config.ali_ai_modle}">
                                        </div>
                                        <div class="layui-form-mid layui-word-aux layui-clear" style="margin-left: 160px;">
                                            <a target="_blank" href="https://bailian.console.aliyun.com/#/home">申请入口</a>
                                        </div>
                                    </div>
                                </div>
                                <div id="ai_deepseek" {if empty($config['ai_api']) || $config['ai_api']!='deepseek'}style="display:none;"{/if}>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label" style="width:130px">DeepSeek APIkey：</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="deepseek_ai_key" class="layui-input" value="{$config.deepseek_ai_key}">
                                        </div>
                                        <div class="layui-form-mid layui-word-aux"></div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label" style="width:130px">DeepSeek模型：</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="deepseek_ai_modle" class="layui-input" value="{$config.deepseek_ai_modle}">
                                        </div>
                                        <div class="layui-form-mid layui-word-aux layui-clear" style="margin-left: 160px;">
                                            <a target="_blank" href="https://platform.deepseek.com/usage">申请入口</a>
                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block" style="margin-left:175px;">
                            <button class="layui-btn" lay-submit lay-filter="formsubmit">提 交</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
    </div>
</div>
<script>
    layui.use(function () {
        layui.laydate.render({
            elem: '#start_hours',
            type: 'time',
            format: 'HH:mm',
            trigger: 'click'
        });
        layui.laydate.render({
            elem: '#end_hours',
            type: 'time',
            format: 'HH:mm',
            trigger: 'click'
        });
        layui.laydate.render({
            elem: '#start_hours1',
            type: 'time',
            format: 'HH:mm',
            trigger: 'click'
        });
        layui.laydate.render({
            elem: '#end_hours1',
            type: 'time',
            format: 'HH:mm',
            trigger: 'click'
        });
        layui.form.on('submit(formsubmit)', function (obj) {
            var field = obj.field
            //哪个选项卡 用于刷新后保持
            var tabindex = 0;
            $('.layui-tab-title>li').each(function (i, v) {
                if ($(this).hasClass('layui-this')) {
                    tabindex = i;
                    console.log(i)
                    return false;
                }
            })
            field.tabindex = tabindex;
            field.inc_type = 'shop';
            var index = layer.load();
            $.post('{:url("handle")}', field, function (data) {
                layer.close(index);
                dialog(data.msg, data.status, data.url);
            })
        })

        layui.form.on('radio(ai_api)', function(data){
            console.log(data);
            var value = data.value;
            if(value=='ali'){
                $('#ai_ali').show();
                $('#ai_deepseek').hide();
            }else if(value=='deepseek'){
                $('#ai_ali').hide();
                $('#ai_deepseek').show();
            }
        });
    })

    function choosezuobiao() {
        var address = $("input[name='info[address]']").val();
        var longitude = $("input[name='info[longitude]']").val();
        var latitude = $("input[name='info[latitude]']").val();
        var choosezblayer = layer.open({
            type: 2,
            shadeClose: true,
            area: ['800px', '560px'],
            'title': '选择坐标',
            content: "{:url('DesignerPage/choosezuobiao')}&address=" + (address ? address : "") + "&jd=" + (longitude ? longitude : "") + "&wd=" + (latitude ? latitude : ""),
            btn: ['确定', '取消'],
            yes: function (index, layero) {
                var longitude = layero.find('iframe').contents().find('#mapjd').val();
                var latitude = layero.find('iframe').contents().find('#mapwd').val();
                $("input[name='info[longitude]']").val(longitude);
                $("input[name='info[latitude]']").val(latitude);
                layer.close(choosezblayer);
            }
        });
    }
</script>
</body>
</html>